<?PHP
@session_start();
require("../inc/common.inc.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php
$action=$_GET['action'];
	if($action=="check"){
		$CheckCode=$_COOKIE['CheckCode'];

		$postnum=$_POST['CheckCode'];
		$name=$_POST['UserName'];
		$pwd=$_POST['Password'];

		if($name==""){
			$fun->popmassage("用户名为空","Login.php","popgotourl");
			exit();
		}
		if($pwd==""){
			$fun->popmassage("密码为空","Login.php","popgotourl");
			exit();
		}
		if($postnum!=$CheckCode){
			$fun->popmassage("验证码不正确","Login.php","popgotourl");
			exit();
		}
		
		
		$pwd=md5($pwd);
		///判断用户名和密码是否正确
		$usernum=$db->excu("SELECT * FROM mx_members WHERE username='$name' and password='$pwd' ");
		if($db->num_rows($usernum)!=1){
			$fun->popmassage("密码或用户名不正确","Login.php","popgotourl");
			exit();
		}else{
            $usernum=$db->fetch_array($usernum);
			if ($usernum["username"]!=trim($name) or $usernum["password"]!=trim($pwd)){
				$fun->popmassage("密码或用户名不正确","Login.php","popgotourl");
				exit();	
			}
			if ($usernum["isok"]==0){
				$fun->popmassage("此用户已经被禁用","Login.php","popgotourl");
				exit();	
			}
			if (trim($usernum["realname"])==""){$usernum["realname"]=$usernum["username"];}
			
			session_cache_expire(30);
			$_SESSION['mxadmin']['username']=$name;
			$_SESSION['mxadmin']['realname']=$usernum["realname"];
			$_SESSION['mxadmin']['userid']=$usernum["uid"];
			$_SESSION['mxadmin']['purview']=$usernum["Purview"];
			$_SESSION['mxadmin']['password']=$usernum[password];
			
			////写入登陆日志
			$ip=$_SERVER['REMOTE_ADDR'];
			$date=date("Y-m-d H:i:s");
			$sql="insert into mx_members_log (userid,username,times,ip) values ('$usernum[uid]','$name','$date','$ip')";
			$db->excu($sql);
			//修改登陆信息
			$sql="update mx_members set LoginTimes=LoginTimes+1,LastLoginIP='$ip',LastLoginTime='$date'  where username='$name' and password='$pwd'";

			$db->excu($sql);
			////
			$fun->popmassage("","Default.php","gotourl");
			exit();
		}
		
}

		  ?>
<TITLE>铭讯EOS网站后台管理</TITLE>
<Meta name="Keywords" Content="济南网站建设 济南网站制作 山东网站建设 济南铭讯软件有限公司">
<Meta name="Description" Content="济南网站制作：铭讯软件专业服务优秀企业，致力于网站建、设网站推广、网络营销一体的全访位网络服务商">
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-image: url(images/bj.jpg);
	background-color: #90bfd5;
}
-->
</style>
<link href="images/style.css" rel="stylesheet" type="text/css">
</head>
<script language=javascript>
<!--
function SetFocus()
{
if (document.Login.UserName.value=="")
	document.Login.UserName.focus();
else
	document.Login.UserName.select();
}
function CheckForm()
{
	if(document.Login.UserName.value=="")
	{
		alert("请输入用户名！");
		document.Login.UserName.focus();
		return false;
	}
	if(document.Login.Password.value == "")
	{
		alert("请输入密码！");
		document.Login.Password.focus();
		return false;
	}
	if (document.Login.CheckCode.value==""){
       alert ("请输入您的验证码！");
       document.Login.CheckCode.focus();
       return(false);
    }
}

//-->
</script>
</head>

<body>
<table width="578" height="650" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top" background="images/1.jpg"><table width="280" border="0" align="center" cellpadding="0" cellspacing="0">
<form name="Login" action="Login.php?action=check" method="post" target="_parent" onSubmit="return CheckForm();">
      <tr>
        <td height="230" colspan="3">&nbsp;</td>
      </tr>
      <tr>
        <td width="53" height="30" class="lan">用户名：</td>
        <td width="165" height="30"><span class="lan1">
                <input type="text" id="UserName" name="UserName" maxlength="64" tabindex="1">
        </span></td>
        <td width="62" rowspan="2"><input type="image" src="images/an.gif" tabindex="4"></td>
      </tr>
      <tr>
        <td height="30" align="left" class="lan">密　码：</td>
        <td height="30"><span class="lan1">
<input type="password" id="Password" name="Password" maxlength="32" tabindex="2">        </span></td>
        </tr>
      <tr>
        <td height="30" align="left" class="lan">验证码：</td>
        <td height="30" colspan="2"><span class="lan1">
          <input name="CheckCode" id="CheckCode" type="text" size="10" tabindex="3">
          <img border="0" name="imageField" src="code.php" onClick="this.src='code.php?dt='+Math.random();" style="cursor:pointer; margin-bottom:-5px;" alt="看不清楚，换一张"></span></td>
      </tr>
</form>
    </table>
      <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="140">&nbsp;</td>
        </tr>
        <tr>
          <td align="center" class="lan1">版权所有 2004-2006 济南铭讯软件有限公司</td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>
